<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">演示</a>
        <a>
          <cite>导航元素</cite></a>
      </span>
	<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="{:url('admin/Cate/index')}" title="刷新">
		<i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
	<div class="layui-row">
		<form class="layui-form layui-col-md12 x-so layui-form-pane">
			<input class="layui-input" placeholder="分类名" name="cate_name">
			<input class="layui-input" placeholder="排序ID" name="orderby">
			<button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon"></i>增加</button>
		</form>
	</div>
	<xblock>
		<button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量删除</button>
		<span class="x-right" style="line-height:40px">共有数据：{$cate->total()} 条</span>
	</xblock>
	<table class="layui-table layui-form">
		<thead>
		<tr>
			<th>
				<div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
			</th>
			<th>ID<a href="{:url('admin/Cate/index',['cate_id'=>'desc'])}"><i class="layui-icon" name="desc" style="font-size: 5px;">&#xe619;</i></a><a href="{:url('admin/Cate/index',['cate_id'=>''])}"><i class="layui-icon" style="font-size: 5px;">&#xe61a;</i></a></th>
			<th>分类名</th>
			<th>排序ID <a href="{:url('admin/Cate/index',['order'=>'desc'])}"><i class="layui-icon" name="desc" style="font-size: 5px;">&#xe619;</i></a><a href="{:url('admin/Cate/index',['order'=>''])}"><i class="layui-icon" style="font-size: 5px;">&#xe61a;</i></a></th>
			<th>操作分类</th>
		</thead>
		<tbody>
		{volist name='cate' id = 'row'}
		<tr>
			<td>
				<div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='{$row.cate_id}'><i class="layui-icon">&#xe605;</i></div>
			</td>
			<td>{$row.cate_id}</td>
			<td>{$row.cate_name}</td>
			<td>{$row.orderby} </td>
			<td class="td-manage">
				<a title="编辑" onclick="x_admin_show('编辑','{:url('admin/Cate/edit',["cate_id"=>$row.cate_id])}')" href="javascript:;">
					<i class="layui-icon">&#xe642;</i>
				</a>
				<a title="删除" onclick="member_del(this,'{$row.cate_id}')" href="javascript:;">
					<i class="layui-icon">&#xe640;</i>
				</a>
			</td>
		</tr>
		{/volist}
		</tbody>
	</table>
</div>
<div class="page">
	{$cate->render()}
</div>
<script>
    layui.use(['form'], function(){
        form = layui.form;
    });
    /*用户-删除*/
    function member_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
          $.post("{:url('admin/Cate/del')}", {cate_id: id}, function(res, textStatus, xhr) {
              if (res.code == 0) {
                  layer.msg(res.msg, function () {
                  });
              } else {
                  layer.alert(res.msg, function () {
                      location.reload();
                  })
              }
          });
        });
    }
    function delAll (argument) {
        var data = tableCheck.getData();
		id = '';
        for (var i in data){
			id += data[i]+',';
		}
        layer.confirm('确认要删除吗？',function(index){
            //捉到所有被选中的，发异步进行删除
            $.post("{:url('admin/Cate/del')}", {cate_id: id}, function(res, textStatus, xhr) {
                if (res.code == 0) {
                    layer.msg(res.msg, function () {
                    });
                } else {
                    layer.alert(res.msg, function () {
                        location.reload();
                    })
                }
            });
        });
    }
</script>
</body>
